﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace TaDMS.Models
{
    public class TaskRepository : Repository<Task>
    {
        public TaskRepository(DbContext model) : base(model)
        {
        }

        public IEnumerable<sp_Task_GetResource_Result> GetComboData(out int? total, int start, int limit, int userId, int isAll)
        {
            try
            {
                using (var db = new TaDMS())
                {
                    var result = db.sp_Task_GetResource(userId, isAll).ToList();
                    total = result.Count();

                    return result.Skip(start).Take(limit);
                }
            }
            catch (Exception exception)
            {
                ErrorMessage = exception.Message;

                total = null;

                return null;
            }
        }
        
    }
}